a, b, c = input().split()

if a == "one":
    a1 = 1 * 100
elif a == "two":
    a1 = 2 * 100
elif a == "three":
    a1 = 3 * 100
elif a == "four":
    a1 = 4 * 100
elif a == "five":
    a1 = 5 * 100
elif a == "six":
    a1 = 6 * 100
elif a == "seven":
    a1 = 7 * 100
elif a == "eight":
    a1 = 8 * 100
elif a == "nine":
    a1 = 9 * 100
elif a == "zero":
    a1 = 0
else:
    print("Wrong input")
    exit(0)

if b == "one":
    b1 = 1 * 10
elif b == "two":
    b1 = 2 * 10
elif b == "three":
    b1 = 3 * 10
elif b == "four":
    b1 = 4 * 10
elif b == "five":
    b1 = 5 * 10
elif b == "six":
    b1 = 6 * 10
elif b == "seven":
    b1 = 7 * 10
elif b == "eight":
    b1 = 8 * 10
elif b == "nine":
    b1 = 9 * 10
elif b == "zero":
    b1 = 0
else:
    print("Wrong input")
    exit(0)

if c == "one":
    c1 = 1
elif c == "two":
    c1 = 2
elif c == "three":
    c1 = 3
elif c == "four":
    c1 = 4
elif c == "five":
    c1 = 5
elif c == "six":
    c1 = 6
elif c == "seven":
    c1 = 7
elif c == "eight":
    c1 = 8
elif c == "nine":
    c1 = 9
else:
    print("Wrong input")
    exit(0)

x = a1 + b1 + c1
if x > 999 or x < 100:
    print("Wrong input")
    exit(0)

count = 0
for i in range(1, x + 1):
    if x % i == 0:
        count += 1
if count == 2:
    print(x)
else:
    for k_right in range(x+1, 10000):
        count = 0
        for i in range(1, k_right + 1):
            if k_right % i == 0:
                count += 1
        if count == 2:
            k_right1 = k_right
            break
    for k_left in range(x-1, 0, -1):
        count = 0
        for i in range(1, k_left + 1):
            if k_left % i == 0:
                count += 1
        if count == 2:
            k_left1 = k_left
            break
    if k_right1 - x < x - k_left1:
        print(k_right1)
    else:
        print(k_left1)
